package cn.chinaiptv.apkmanager.bean;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * EPG推荐位bean
 * 
 * @author Administrator
 *
 */
public class Epgrecomm {
	private int epgrecomm_id;
	private String epgrecomm_platform;
	private String epgrecomm_option;
	private String epgrecomm_poscode;
	private String epgrecomm_title;
	private String epgrecomm_icon;
	private int epgrecomm_linktype;
	private String epgrecomm_linkobjtype;
	private String epgrecomm_linkobjvalue;
	private int epgrecomm_status;
	private String epgrecomm_validtime;
	private String epgrecomm_expiretime;

	/**
	 * 跑马灯post参数
	 * 
	 * @param epgrecomms
	 * @return
	 */
	public static String getPostJson(ArrayList<Epgrecomm> epgrecomms) {
		JSONObject obj = new JSONObject();
		JSONObject headerObj = new JSONObject();
		JSONObject bodyObj = new JSONObject();
		JSONArray positemsArray = new JSONArray();
		String result = null;
		try {
			// 封装头部
			headerObj
					.put("paltform", epgrecomms.get(0).getEpgrecomm_platform());
			headerObj.put("option", epgrecomms.get(0).getEpgrecomm_option());
			obj.put("header", headerObj);
			// 封装body
			for (int i = 0; i < epgrecomms.size(); i++) {
				JSONObject tempObj = new JSONObject();
				tempObj.put("poscode", epgrecomms.get(i).getEpgrecomm_poscode());
				tempObj.put("title", epgrecomms.get(i).getEpgrecomm_title());
				tempObj.put("icon", epgrecomms.get(i).getEpgrecomm_icon());
				tempObj.put("linktype", epgrecomms.get(i)
						.getEpgrecomm_linktype());
				tempObj.put("linkobjtype", epgrecomms.get(i)
						.getEpgrecomm_linkobjtype());
				tempObj.put("linkobjvalue", epgrecomms.get(i)
						.getEpgrecomm_linkobjvalue());
				tempObj.put("status", epgrecomms.get(i).getEpgrecomm_status());
				tempObj.put("validtime", epgrecomms.get(i)
						.getEpgrecomm_validtime());
				tempObj.put("expiretime", epgrecomms.get(i)
						.getEpgrecomm_expiretime());
				positemsArray.put(i, tempObj);
			}
			bodyObj.put("positems", positemsArray);
			obj.put("body", bodyObj);
			result = obj.toString();
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return result;
	}

	@Override
	public String toString() {
		return "Epgrecomm [epgrecomm_id=" + epgrecomm_id
				+ ", epgrecomm_platform=" + epgrecomm_platform
				+ ", epgrecomm_option=" + epgrecomm_option
				+ ", epgrecomm_poscode=" + epgrecomm_poscode
				+ ", epgrecomm_title=" + epgrecomm_title + ", epgrecomm_icon="
				+ epgrecomm_icon + ", epgrecomm_linktype=" + epgrecomm_linktype
				+ ", epgrecomm_linkobjtype=" + epgrecomm_linkobjtype
				+ ", epgrecomm_linkobjvalue=" + epgrecomm_linkobjvalue
				+ ", epgrecomm_status=" + epgrecomm_status
				+ ", epgrecomm_validtime=" + epgrecomm_validtime
				+ ", epgrecomm_expiretime=" + epgrecomm_expiretime + "]";
	}

	public int getEpgrecomm_id() {
		return epgrecomm_id;
	}

	public void setEpgrecomm_id(int epgrecomm_id) {
		this.epgrecomm_id = epgrecomm_id;
	}

	public String getEpgrecomm_platform() {
		return epgrecomm_platform;
	}

	public void setEpgrecomm_platform(String epgrecomm_platform) {
		this.epgrecomm_platform = epgrecomm_platform;
	}

	public String getEpgrecomm_option() {
		return epgrecomm_option;
	}

	public void setEpgrecomm_option(String epgrecomm_option) {
		this.epgrecomm_option = epgrecomm_option;
	}

	public String getEpgrecomm_poscode() {
		return epgrecomm_poscode;
	}

	public void setEpgrecomm_poscode(String epgrecomm_poscode) {
		this.epgrecomm_poscode = epgrecomm_poscode;
	}

	public String getEpgrecomm_title() {
		return epgrecomm_title;
	}

	public void setEpgrecomm_title(String epgrecomm_title) {
		this.epgrecomm_title = epgrecomm_title;
	}

	public String getEpgrecomm_icon() {
		return epgrecomm_icon;
	}

	public void setEpgrecomm_icon(String epgrecomm_icon) {
		this.epgrecomm_icon = epgrecomm_icon;
	}

	public int getEpgrecomm_linktype() {
		return epgrecomm_linktype;
	}

	public void setEpgrecomm_linktype(int epgrecomm_linktype) {
		this.epgrecomm_linktype = epgrecomm_linktype;
	}

	public String getEpgrecomm_linkobjtype() {
		return epgrecomm_linkobjtype;
	}

	public void setEpgrecomm_linkobjtype(String epgrecomm_linkobjtype) {
		this.epgrecomm_linkobjtype = epgrecomm_linkobjtype;
	}

	public String getEpgrecomm_linkobjvalue() {
		return epgrecomm_linkobjvalue;
	}

	public void setEpgrecomm_linkobjvalue(String epgrecomm_linkobjvalue) {
		this.epgrecomm_linkobjvalue = epgrecomm_linkobjvalue;
	}

	public int getEpgrecomm_status() {
		return epgrecomm_status;
	}

	public void setEpgrecomm_status(int epgrecomm_status) {
		this.epgrecomm_status = epgrecomm_status;
	}

	public String getEpgrecomm_validtime() {
		return epgrecomm_validtime;
	}

	public void setEpgrecomm_validtime(String epgrecomm_validtime) {
		this.epgrecomm_validtime = epgrecomm_validtime;
	}

	public String getEpgrecomm_expiretime() {
		return epgrecomm_expiretime;
	}

	public void setEpgrecomm_expiretime(String epgrecomm_expiretime) {
		this.epgrecomm_expiretime = epgrecomm_expiretime;
	}

	public Epgrecomm() {
		super();
	}

	public Epgrecomm(String epgrecomm_platform, String epgrecomm_option,
			String epgrecomm_poscode, String epgrecomm_title,
			String epgrecomm_icon, int epgrecomm_linktype,
			String epgrecomm_linkobjtype, String epgrecomm_linkobjvalue,
			int epgrecomm_status, String epgrecomm_validtime,
			String epgrecomm_expiretime) {
		super();
		this.epgrecomm_platform = epgrecomm_platform;
		this.epgrecomm_option = epgrecomm_option;
		this.epgrecomm_poscode = epgrecomm_poscode;
		this.epgrecomm_title = epgrecomm_title;
		this.epgrecomm_icon = epgrecomm_icon;
		this.epgrecomm_linktype = epgrecomm_linktype;
		this.epgrecomm_linkobjtype = epgrecomm_linkobjtype;
		this.epgrecomm_linkobjvalue = epgrecomm_linkobjvalue;
		this.epgrecomm_status = epgrecomm_status;
		this.epgrecomm_validtime = epgrecomm_validtime;
		this.epgrecomm_expiretime = epgrecomm_expiretime;
	}

}
